home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
prolog
/
modprolg
/
mod-prol.lha
/
Prolog
/
modlib
/
src
/
$prag.P
< prev
next >
Wrap
Text File
|
1992-06-01
|
3KB
|
82 lines
/************************************************************************
* *
* The SB-Prolog System *
* Copyright SUNY at Stony Brook, 1986; University of Arizona, 1987 *
* *
************************************************************************/
/*-----------------------------------------------------------------
SB-Prolog is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY. No author or distributor
accepts responsibility to anyone for the consequences of using it
or for whether it serves any particular purpose or works at all,
unless he says so in writing. Refer to the SB-Prolog General Public
License for full details.
Everyone is granted permission to copy, modify and redistribute
SB-Prolog, but only under the conditions described in the
SB-Prolog General Public License. A copy of this license is
supposed to have been given to you along with SB-Prolog so you
can know your rights and responsibilities. It should be in a
file named COPYING. Among other things, the copyright notice
and this notice must be preserved on all copies.
------------------------------------------------------------------ */
/* $prag.P */
$prag_export([$get_prag/2]).
% $prag_use : $name, $bio, $read, $blist, $bmeta
$get_prag(Infile,Prag) :-
$name(Infile,InfileName), $append(InfileName,".def",PFileName),
$name(PFile,PFileName),
(
((exists(PFile), PragFile = PFile, !) ;
($name(DefFile,[100,101,102,115,47|PFileName]), /* defs/foo.def */
exists(DefFile), PragFile = DefFile, !
)
),
$seeing(CurrIn), $see(PragFile),
$get_prag1(PragL,[]),
$seen, $see(CurrIn),
$sort_prag(PragL,Prag)
) ;
($telling(CurrOut), $tell(user),
$writename('*** warning: no pragma file for '),
$writename(Infile), $nl,
$told, $tell(CurrOut),
Prag = []
).
$get_prag1(P,PTail) :-
$read(Prag),
(Prag = end_of_file -> P = PTail ;
(P = [Prag | PMid], $get_prag1(PMid,PTail))
).
$sort_prag([],L) :- $prag_closetail(L), !.
$sort_prag([prag(P,N,Prag)|PRest],L) :-
$prag_listify(Prag,PragL),
$member1(prag(P,N,PragList),L),
$prag_attach(PragL,PragList),
$sort_prag(PRest,L).
$prag_listify(Prag,PragL) :-
Prag = [_|_] -> $append(Prag,_,PragL) ; PragL = [Prag|_].
$prag_attach(PragL,PragList) :-
(var(PragList), PragList = PragL) ;
(nonvar(PragList), PragList = [_|PragListTail],
$prag_attach(PragL, PragListTail)
).
$prag_closetail([]).
$prag_closetail([prag(P,N,PragL)|L]) :-
$prag_closetail0(PragL), $prag_closetail(L).
$prag_closetail0([]).
$prag_closetail0([_|L]) :- $prag_closetail0(L).
/* ------------------------------ $prag.P ------------------------------ */